<?php

/*
	@version SVN: $Id: mysql.php 2 2007-10-12 16:56:15Z desolator $

	Copyright (C) 2007 The ActySofts Organization

	This file is part of Sampi.

	Sampi is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	Sampi is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with SauthSQL; if not, write to the Free Software
	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

/*
	@description This is the MySQL object. It will handle all the MySQL stuff.

	@see The database wrapper.

	@todo Complete it with all required functions.

	@author Desolator
*/
class MySQL
{
	/*
		@description This function will connect to the MySQL server.

		@arg $DB_Server The MySQL server to connect to.

		@arg $DB_Username The MySQL username that will be used to connect.

		@arg  $DB_Password The MySQL of the MySQL username.

		@return The MySQL database handle.

		@see pconnect($DB_Server, $DB_Username, $DB_Password);

		@author Desolator
	*/
	function connect($DB_Server, $DB_Username, $DB_Password)
	{
		// Connect to the MySQL server
		return mysql_connect($DB_Server, $DB_Username, $DB_Password);
	}

	/*
		@description This function will connect to the MySQL server and keep the connection alive.

		@arg $DB_Server The MySQLserver to connect to.

		@arg $DB_Username The MySQL username that will be used to connect.

		@arg  $DB_Password The MySQL of the MySQL username.

		@see connect($DB_Server, $DB_Username, $DB_Password);

		@return The MySQL database handle.

		@author Desolator
	*/
	function pconnect($DB_Server, $DB_Username, $DB_Password)
	{
		// Connect to the MySQL server and keep the connection alive
		return mysql_pconnect($DB_Server, $DB_Username, $DB_Password);
	}

	/*
		@description This function will escape special characters in a string for use in a SQL statement.

		@author Desolator
	*/
	function escape_string($SQL_Statement)
		// Escape the special characters
		return mysql_real_escape_string($SQL_Statement);
	}

	/*
		@description This function will send a MySQL query for processing.

		@author Desolator
	*/
	function query($SQL_Statement, $DB_Handle)
		// Escape the special characters
		return mysql_query($SQL_Statement, $DB_Handle);
	}

	/*
		@description This function will close the connection to the MySQL server.

		@arg  $DB_Handle The handle of the MySQL connection to close.

		@author Desolator
	*/
	function close($DB_Hanlde)
	{
		// Close the non-persistent connection
		mysql_close($DB_Hanlde);
	}

	/*
		@description This function will select a MySQL database that will be used.

		@arg  $DB_Name The name of the MySQL database to use.

		@arg  $DB_Handle The handle of the MySQL connection to select.

		@author Desolator
	*/
	function select_db($DB_Name, $DB_Hanlde)
	{
		// Select the MySQL database
		mysql_select_db($DB_Name, $DB_Hanlde);
	}
}

?>